﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JavaScriptSample._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Simple Ajax Request</title>

    <script type="text/javascript">
        function loadContent()
        {
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                this.xmlhttp = new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                try
                {
                    this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e1)
                {
                    try
                    {// older version of Msxml
                        this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e2)
                    {
                        this.xmlhttp = null;
                    }
                }
            }
            xmlhttp.onreadystatechange = function()
            {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                {// Display response when success.
                    document.getElementById("SimpleAjaxResponse").innerHTML = xmlhttp.responseText;
                }
            }
            this.xmlhttp.open("GET", "AjaxResponse.txt", true);
            this.xmlhttp.send();
        }
    </script>

</head>
<body>
    <form id="SimpleAjaxRequestForm" runat="server">
    <div>
        <asp:Button ID="SimpleAjaxRequestButton" runat="server" Text="Request" />
        <div id="SimpleAjaxResponse" runat="server">
        </div>
    </div>
    </form>
</body>
</html>
